<?php

/**
 * verwaltung actions.
 *
 * @package    adminslittlehelper
 * @subpackage verwaltung
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class updateCategoryAction extends sfAction
{
  /**
   * Executes index action
   *
   */
  public function execute()
  {
    if (!$this->getRequestParameter('id'))
    {
      $category = new Kategorie();
    }
    else
    {
      $category = KategoriePeer::retrieveByPk($this->getRequestParameter('id'));
      $this->forward404Unless($category);
    }

    $category->setId($this->getRequestParameter('id'));
    $category->setBenutzerId(1);
    $category->setName($this->getRequestParameter('name'));
    if ($this->getRequestParameter('updated_on'))
    {
      list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('updated_on'), $this->getUser()->getCulture());
      $category->setUpdatedOn("$y-$m-$d");
    }

    $category->save();
    bwUtils::saveAddFields($category);
    
    return $this->redirect('softwareservices/showOverview?id='.$category->getId());
  }
}
